/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __AB4CB0C2_0E67_4615_B663_04E6B5057834__
#define __AB4CB0C2_0E67_4615_B663_04E6B5057834__

#include "../macro/head.h"
#include "../release/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 
namespace xos
{
    // 
    // dynamic interface
    // 
    class i_dynamic : public i_release
    {
    protected:
        virtual ~i_dynamic(){}

    public:
        // 
        // combine load and get_proc_by_name.
        // 
        // 1.try to load : lpszPath/lpszFileName.ext
        // 
        virtual int load_and_get( void ** ppv, const char * lpszPath, const char * lpszFileName, const char * lpszProcName, 
            const char * lpszExt = "xos" ) = 0;

        // 
        // when lpszExt = 0, use different ext whith different platform. win is dll, linux32 is so, mac is dylib
        // otherwise, use lpszExt
        // lpszExt like : dll, so, dylib or other user defined name.
        // 
        virtual int load( const char * lpszFullPath, const char * lpszFile, const char * lpszExt = "xos" ) = 0;

        //
        // 方便函数，感觉之前的实现有毛病，太复杂了
        // 
        virtual int load_and_get( void ** ppv, const char * lpszFullFile, const char * lpszProcName ) = 0;
        virtual int load( const char * lpszFullFile ) = 0;

        // 
        // get proc address by name
        // 
        virtual int get_proc_by_name( void ** ppv, const char * lpszProcName ) = 0;

        // 
        // get full path and file name
        // 
        virtual const char * get_full_path( char * lpszFullPath, int nBufSize ) = 0;
        virtual const char * get_file_name( char * lpszFileName, int nBufSize ) = 0;

        // 
        // free loaded module
        //
        virtual int free() = 0;
    };
}

#endif // __AB4CB0C2_0E67_4615_B663_04E6B5057834__
